package demo.activity;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;

import com.benz.fastblur.Fast2Blur;

import demo.zandroid.R;


public class FastBlurDemo extends Activity {
	boolean isBlur = false;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_fastblur);
		final ImageView iv = (ImageView) findViewById(R.id.blur);
		iv.setImageResource(R.drawable.test);

		Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
				R.drawable.test);
		float start = System.currentTimeMillis();
		final Bitmap blur = bitmap;
		try {
			Fast2Blur.build(blur, 99);
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println("fast 2 blur : "
				+ (System.currentTimeMillis() - start));

		Button bt = (Button) findViewById(R.id.bt);
		bt.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				if (isBlur) {
					iv.setImageResource(R.drawable.test);
				} else {
					iv.setImageBitmap(blur);
				}
				isBlur = !isBlur;
			}
		});
	}
}
